package com.android.smsmessing;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.android.smsmessing.widgets.RadioStateDrawable;
import com.android.smsmessing.widgets.ScrollableTabActivity;

public class SMSMessingTabActivity extends ScrollableTabActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setDelegate(new SliderBarActivityDelegateImpl());
        /*
         * optional
         * set default off and on color shades of tab bar button
         * if not specified, opaque areas are shaded gray in off state, and yellow in on state 
         */
        setDefaultShade(RadioStateDrawable.SHADE_GRAY, RadioStateDrawable.SHADE_GREEN);
        
        this.addTab("短信列表", R.drawable.star, new Intent(this, SMSInboxActivity.class));
        this.addTab("已保存", R.drawable.star, new Intent(this, SMSActivity_bak.class));
//        for (int i=0; i<14; i++)
//        {
//        	Intent intent;
//        	if (i%2==0) intent = new Intent(this, DemoActivity1.class);
//        	else intent = new Intent(this, DemoActivity2.class);
//        	
//        	/*
//        	 * This adds a title, and an image to the tab bar button
//        	 * Image should be a PNG file with transparent background.
//        	 * By default, opaque areas are shaded gray in off state, and yellow in on state 
//        	 */
//        	this.addTab("title"+i, R.drawable.star, intent);
//        	
//        }
        
        /*
         * commit is required to redraw the bar after add tabs are added
         * if you know of a better way, drop me your suggestion please.
         */
        commit();
//        final TabHost tabHost = getTabHost();
////        Drawable mySelector = getResources().getDrawable(R.drawable.tabselector);
//        tabHost.addTab(tabHost.newTabSpec("smsList")
//                .setIndicator("短信列表")
//                .setContent(new Intent(this, SMSInboxActivity.class)));
//
//        tabHost.addTab(tabHost.newTabSpec("smsBak")
//                .setIndicator("已保存")
//                .setContent(new Intent(this, SMSActivity_bak.class)));
//        
//        // This tab sets the intent flag so that it is recreated each time
//        // the tab is clicked.
////        tabHost.addTab(tabHost.newTabSpec("tab3")
////                .setIndicator("destroy")
////                .setContent(new Intent(this, Controls2.class)
////                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
    }
    
    private class SliderBarActivityDelegateImpl extends SliderBarActivityDelegate
    {
    	/*
    	 * Optional callback method
    	 * called when users tap on the tab bar button
    	 */
    	protected void onTabChanged(int tabIndex) 
    	{
    		Log.d("onTabChanged",""+tabIndex);
    	}
    }
}
